<%--
  Created by IntelliJ IDEA.
  User: 13939
  Date: 2024/11/28
  Time: 11:36
  To change this template use File | Settings | File Templates.
--%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>新闻发布</title>
  <link rel="stylesheet" href="../styles/newStyles.css">
  <script src="../scripts/news.js"></script>
</head>
<body>
<%
  //检测用户是否已经登陆了
  String username  = (String) session.getAttribute("username");


  if(username==null){
    response.sendRedirect("/login/login.jsp");
    return;  //!!!!!不能少  返回  不执行下面的语句
  }else{
%>

<div class="container mt-5">
  <div class="row justify-content-center">
    <div class="col-md-6">
      <form action="saveNews.jsp" method="post" onsubmit="return news()">
        <div class="form-group">
          <label for="newsTitle">文章标题</label>
          <input type="text" class="form-control" id="newsTitle" name="newsTitle" placeholder="请输入标题" required>
        </div>
        <div class="form-group">
          <label for="newsContent">文章内容</label>
          <textarea class="form-control" id="newsContent" name="newsContent" rows="5" placeholder="请输入内容" required></textarea>
        </div>
        <div class="form-group">
          <label for="newsCategory">文章类别</label>
          <select class="form-control" id="newsCategory" name="newsCategory">
            <option value="0">选择文字类型</option>
            <option value="1">新闻</option>
            <option value="2">体育</option>
            <option value="3">娱乐</option>
            <option value="4">科技</option>
            <option value="5">其他</option>
          </select>
        </div>
        <button type="submit" class="btn btn-primary">保存</button>
        <a href="../show/show.jsp" class="btn btn-secondary ml-2">取消</a>
        <div id="error-message" style="color: red;"></div>
      </form>
    </div>
  </div>
</div>

</body>
<%}%>
</html>
